package gui;

import javax.swing.JSplitPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class SplitPaneDemo2 extends JSplitPane
                            implements ListSelectionListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3295664277126793072L;

	//public static JTextArea jta;
	
    public SplitPaneDemo2() {
    	
       /// super("Image Managing Web Service");

        //Create an instance of SplitPaneDemo
        SplitPaneDemo splitPaneDemo = new SplitPaneDemo();
        JSplitPane top = splitPaneDemo.getSplitPane();
        splitPaneDemo.getImageList().addListSelectionListener(this);

        //XXXX: Bug #4131528, borders on nested split panes accumulate.
        //Workaround: Set the border on any split pane within
        //another split pane to null. Components within nested split
        //panes need to have their own border for this to work well.
        //top.setBorder(null);

        //Create a regular old label
        //JLabel label = new JLabel("Click on an image name in the list.", JLabel.CENTER);
       
        TabsPane tp = new TabsPane(splitPaneDemo.getImageList());
        
      /*  JPanel panel1 = new JPanel(false);
       // jta = new JTextArea("Shell ???");
        panel1.setLayout(new GridLayout(1, 1));
        //panel1.add(jta);
        
        JPanel panel2 = new JPanel(false);
        JLabel filler2 = new JLabel("TODO : Interface graphique");
        filler2.setHorizontalAlignment(JLabel.CENTER);
        panel2.setLayout(new GridLayout(1, 1));
        panel2.add(filler2);*/
        
        //tp.addTab("Shell", null, panel1, "Affiche un shell pour interagir en ligne de commande");
        //tp.addTab("GUI", null, panel2, "Affiche une interface graphique pour interagir avec le programme");
        
        //tab = new TabsPane();

        //Create a split pane and put "top" (a split pane)
        //and JLabel instance in it.
      //  JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
          //                                    top, tab);
        
       this.setOrientation(JSplitPane.VERTICAL_SPLIT);
        this.setTopComponent(top);
        this.setBottomComponent(tp);
      //  splitPane.setOneTouchExpandable(true);
        //splitPane.setDividerLocation(180);

        this.setOneTouchExpandable(true);
        this.setDividerLocation(700);
        
        //Provide minimum sizes for the two components in the split pane
      //  top.setMinimumSize(new Dimension(500, 300));
        //tab.setMinimumSize(new Dimension(0, 700));
        //this.setPreferredSize(new Dimension(1000, 500));

        //Add the split pane to this frame
        //this.add(splitPane);
        
    }

    public void valueChanged(ListSelectionEvent e) {
        if (e.getValueIsAdjusting())
            return;

     /*   JList theList = (JList)e.getSource();
        if (theList.isSelectionEmpty()) {
            label.append("Nothing selected.");
        } else {
            int index = theList.getSelectedIndex();
            label.append("Selected image number " + index);
        }*/
    }
    
    
   /* public static void print(String str) {
    	do {
    		
    	} while(jta == null);
    	jta.append(str);
    }
    
    public static void println(String str) {
    	do {
    		
    	} while(jta == null);
    	jta.append(str+"\n");
    }*/
    

    /*public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }*/
}